<?php

/**
 * @author Christopher Hazekamp
 * @copyright 2013
 */

//$db = new PDO("mysql:host=localhost;dbname=portfolio_db;", 'root', '');
//$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//$db->setFetchMode(PDO::FETCH_ASSOC);
require('pdo.php');
$db = new Database;
$id = (isset($_GET['id'])) ? $_GET['id'] : 0;
if (!$id)
{
	exit;
}
?>

<a href="index.php">Overzicht</a>

<?php
if (isset($_POST['submit']))
{
	$db->sqlDelete('people', $post, 'id', $id);
	echo '<br />Objected deleted!';
}
else
{
?>
<table>
	<tr>
		<th>ID</th>
		<th>Name</th>
		<th>Location</th>
		<th>Gender</th>
	</tr>
<?php
$db->query("SELECT * FROM people WHERE id = :id");
$db->bind(':id', $id);
$row = $db->single();
switch ($row['gender'])
{
	case 'f': $row['gender'] = 'Female';	break;
	case 'm': $row['gender'] = 'Male';	break;
	default : $row['gender'] = 'N/A';	break;
}
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['location'] . "</td>";
echo "<td>" . $row['gender'] . "</td>";
echo "</tr>";


?>

</table>
<form action="" method="post" id="editvalue">		
		<input type="submit" name="submit" value="Delete" />
	</form>
<?php } ?>